package com.css.dzj.dzjdzqs.modules.datafromzfjg.service.impl;

import com.alibaba.fastjson.JSON;
import com.css.dzj.dzjdzqs.common.util.HttpClientUtil;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.entity.JgLhjgRwsEntity;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.mapper.JgLhjgRwsMapper;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.service.JgLhjgRwsService;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.vo.JgLhjgRwsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JgLhjgRwsServiceImpl implements JgLhjgRwsService {
    @Value("${ZFJG_URL}")
    private String zfjgUrl;
    @Autowired
    private JgLhjgRwsMapper jgLhjgRwsMapper;
    @Override
    public void addLhjgRwsMsg()  {
        try {
            String list = HttpClientUtil.doGet(zfjgUrl + "/lhjgrwbl/queryAllRwsMsg");
            List<JgLhjgRwsVo> results = JSON.parseArray(list, JgLhjgRwsVo.class);
            for (JgLhjgRwsVo result : results) {
                JgLhjgRwsEntity jgLhjgRwsEntity = new JgLhjgRwsEntity();
                jgLhjgRwsEntity.setTaskid(result.getTaskId());
                jgLhjgRwsEntity.setTaskno(result.getTaskno());
                jgLhjgRwsEntity.setTaskname(result.getTaskname());
                jgLhjgRwsEntity.setReportregionNo(result.getReportregionno());
                jgLhjgRwsEntity.setReportregionName(result.getReportregionname());
                jgLhjgRwsEntity.setInitiateunitNo(result.getInitiateunitno());
                jgLhjgRwsEntity.setInitiateunitName(result.getInitiateunitname());
                jgLhjgRwsEntity.setUniondeptNo(result.getUniondeptno());
                jgLhjgRwsEntity.setUniondeptName(result.getUniondeptname());
                jgLhjgRwsEntity.setSuperviseobjectNo(result.getSuperviseobjectno());
                jgLhjgRwsEntity.setInspectcontent(result.getInspectcontent());
                jgLhjgRwsEntity.setInspectclaim(result.getInspectclaim());
                jgLhjgRwsEntity.setTaskStarttime(result.getTaskstarttime());
                jgLhjgRwsEntity.setTaskEndtime(result.getTaskendtime());
                jgLhjgRwsEntity.setRemark(result.getRemark());
                jgLhjgRwsMapper.save(jgLhjgRwsEntity);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
